// miniprogram/pages/tool/tool.js
var gzry_ruler;
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imga1: ['https://7a6d-zmyy-6uke0-1301213777.tcb.qcloud.la/%E5%8C%BB%E9%99%A2.ico?sign=494533ee962e6604bb4fb02c438197f8&t=1580971286'],
    imga2: ['https://7a6d-zmyy-6uke0-1301213777.tcb.qcloud.la/%E8%BD%A6%E7%AB%99.ico?sign=ef3aea82efb16800681cb2fafb2a4fd5&t=1580971305'],
    imga3: ['https://7a6d-zmyy-6uke0-1301213777.tcb.qcloud.la/%E5%B0%8F%E5%8C%BA.ico?sign=40e683c45d72155f8011441ddfc3f4c4&t=1580971318'],
    imga4: ['https://7a6d-zmyy-6uke0-1301213777.tcb.qcloud.la/%E5%9F%8E%E5%B8%82.ico?sign=fa0a662bfa1c338becb0f21c0f9187f9&t=1580971331'],
    imga5: ['https://7a6d-zmyy-6uke0-1301213777.tcb.qcloud.la/%E5%B0%91%E5%87%BA%E9%97%A8.jpg?sign=6ccd315f30f826a47285735681d6388c&t=1580886549'],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
this.findOpenid();
  },
  hospital: function (e) {
    // console.log('glry_ruler1111: ', glry_ruler)
    if (gzry_ruler==1){
      wx.redirectTo({
      url: '../info/hospital/hospital',
    })
    } 
    else {
      wx.showToast({
        title: '没有权限',
        icon: 'success'
      })
    }
  },
  station: function (e) {
    if (gzry_ruler == 2) {
    wx.navigateTo({
      url: "../info/station/station",
    })
    }
    else {
      wx.showToast({
        title: '没有权限',
        icon: 'success'
      })}
  },
  xiaoqu: function (e) {
   
    if (gzry_ruler == 3) {
      wx.navigateTo({
        url: '../info/xiaoqu/xiaoqu',
      })
    }
    else {
      wx.showToast({
        title: '没有权限',
        icon: 'success'
      })
    }
  },
  public: function (e) {
    

    // if (gzry_ruler == 4) {
      wx.navigateTo({
        url: '../info/public/public',
      })
    // }
    // else {
    //   wx.showToast({
    //     title: '没有权限',
    //     icon: 'success'
    //   })
    // }
  },
  findOpenid: function () {
    var that = this;
    const db = wx.cloud.database();
    wx.cloud.callFunction({
      name: 'login',
      complete: res => {
        app.globalData.openid = res.result.openid
        db.collection('glry').where({
          _openid: app.globalData.openid
        })
          .get()
          .then(res => {
            if (res.data.length) {
              // console.log('glry_ruler:res.data ', res.data)
              gzry_ruler = res.data[0].gzry_ruler
              console.log('gzry_ruler: ', gzry_ruler)
            }
            else {
              // console.log('没e有人员信息', res.data)
              // console.log('this.data.modalHidden1', this.data.modalHidden1)
              // this.setData({
              //   tbry: "请到 服务中心-->工作人员绑定 后再使用扫码功能！"
              // })
            }
          })
      }
    })


  },
})